//引入二次封装axios
import axios from '@/utils/request'
//数据类型接口
import { TradeMarkData, TradeMark, markResponseData } from './type'
//枚举接口地址
enum API {
  //品牌接口分页列表page第几页,limit每页多少条
  TRADEMARK_URL = '/admin/product/baseTrademark/',
  //新增品牌
  ADDTRADEMARK_URL = '/admin/product/baseTrademark/save',
  //修改品牌信息
  UPDATETRADEMARK_URL = '/admin/product/baseTrademark/update',
  //删除品牌信息
  DELETETRADEMARK_URL = '/admin/product/baseTrademark/remove/',
}
//获取已有品牌的接口方法
export const reqHasTrademark = (page: number, limit: number) =>
  axios.get<any, TradeMarkData>(API.TRADEMARK_URL + `${page}/${limit}`)
//新增品牌信息
export const reqAddOrUpdateTrademark = (data: TradeMark) => {
  if (data.id) {
    return axios.put<any, any>(API.UPDATETRADEMARK_URL, data)
  } else {
    return axios.post<any, any>(API.ADDTRADEMARK_URL, data)
  }
}
export const reqDeleteTradeMark = (id: number | undefined) =>
  axios.delete<any, markResponseData>(API.DELETETRADEMARK_URL + id)
